<?php $this->placeholder('display-commercial1')->set(1)?>
<?php 
    if ($this->category->customization =='job') {
        $this->placeholder('container-class')->set('cat_index job');
    } elseif ($this->category->id == 'mc52') { //business directory
        $this->placeholder('container-class')->set('cat_index business directory');
    } else {
        $this->placeholder('container-class')->set('cat_index');
    }
?>
<?php $this->headLink()->appendStylesheet(Ac_Util::getImageBaseUrl('/css/custom_cat_index.v-'.AC_VERSION.'.css'))?>
<?php $this->JQuery()->addJavascriptFile(Ac_Util::getImageBaseUrl('/js/custom_category_index.v-'.AC_VERSION.'.js')) ?>
<?php $this->JQuery()->addJavascriptFile(Ac_Util::getImageBaseUrl('/js/slideshow/jquery.nivo.slider.v-'.AC_VERSION.'.js'))?>
<?php $this->JQuery()->addJavascriptFile(Ac_Util::getImageBaseUrl('/js/formatter/jquery.formatter.v-'.AC_VERSION.'.js')) ?>
<article class="article">
<section class="main_section">
    <section class="title">
        <h1><?php echo $this->category->name?></h1>
        <?php if(!empty($this->random_users)):?>
            <section class="usersThumb">
                <h4>他们也在此发布宝贝</h4>
                <p>
                    <?php foreach($this->random_users as $user):?>
                        <?php if(!empty($user->cid)):?>
                           <a href="<?php echo $user->company->url();?>">
                               <img src="<?php echo $this->thumbnail()->scale($user->company->image, 24, 24, true, true);?>" alt="<?php echo $user->company->company_name?>">
                           </a>
                        <?php else:?>
                            <a href="<?php echo $user->url();?>">
                                <img src="<?php echo $this->thumbnail()->scale($user->pp, 24, 24, true, true);?>" alt="<?php echo $user->username?>">
                            </a>
                        <?php endif?>
                    <?php endforeach;?>
                </p>
            </section>
        <?php endif;?>
    </section>
    <section class="main_info box">
        <section class="ad leader">
            <!--a href="#"><img src="images/ad_728_90.jpg"></a-->
        </section>
        <section class="left column">
            <section class="refine">
                <h3>找<?php echo $this->category->name?></h3>
<?php               
                    $get = $_GET;
                    //$get['small_category_list'] = 1;
                    $this->partial()->setObjectKey('model');
                    echo $this->partial('index/customization/facet-box.phtml', 'search', array(
                        'disabled_facet'  => $this->disabled_facet,
                        'force_facet'   => $this->force_facet,
                        'url'           => '/search/regular?small_category_list='.$this->category->_id,
                        'separator'     => '&',
                        'get'           => $get
                    ));
                     
                ?>
            </section>
            
            <section class="mkt">
                <ul>
                    <li class="newsletter">
						<dl>
							<dt>
								<h3><a href="/default/index/newsletter">免费与猫找网互动</a></h3>
							</dt>
							<dd>订阅业务简报，紧贴猫找网最新宝贝信息、推广优惠及最新动态。<a href="/default/index/newsletter">立即订阅</a></dd>
						</dl>
					</li>
					<li class="bulk">
						<dl>
							<dt>
								<h3><a href="/default/index/bulk-listing">免费商家营销服务 </a></h3>
							</dt>
							<dd>不需逐一发布宝贝，开通猫找网免费“商家营销服务”，即可批量发布你图文并茂的宝贝。<a href="/default/index/bulk-listing">在线申请</a></dd>
						</dl>
					</li>
					<li class="business_acc">
						<dl>	
							<dt>
								<h3><a href="/user/register-business">免费注册商家帐户 </a></h3>
							</dt>
							<dd>注册商家账户，你的公司即可纳入猫找网行业目录，并免费开通“商家营销服务”。<a href="/user/register-business">立即注冊</a></dd>
						</dl>
					</li>
                </ul>
            </section>

            <?php 
                $display_photo = true;
                $display_user  = true;
                $class = 'gallery';
                $replace_like_with_follow = false;
                $display_price = true;
                $display_function = true;
                $display_customization = false;
                if ($this->category->customization == 'job') {
                    $display_photo = false;
                    $display_user  = false;
                    $class = '';
                } elseif ($this->category->id == 'mc52') { //business directory
                    $display_photo = false;
                    $display_user  = false;
                    $class = 'user';
                    $replace_like_with_follow = true;
                    $display_function = false;
                    $display_price = false;
                    $display_customization = true;
                }
            ?>
            <section class="new <?php echo $class?> hor">
                <h3>最新宝贝</h3>
                <ul>
                    <?php  foreach ($this->newstuff as $item):?>
                        <li>    
                            <?php
                                $this->partial()->setObjectKey('model');
                                echo $this->partial(
                                    'index/listing-element.phtml',
                                    'search',
                                    array(
                                        'item'                        => $item,
                                        'photo_width'                 => 190,
                                        'photo_height'                => 190,
                                        'photo_params'                => array(),
                                        'display_photo'               => $display_photo, 
                                        'display_user'                => $display_user,
                                        'display_photo_if_not_exists' => true,
                                        'display_category'            => false,
                                        'display_customization'       => $display_customization,
                                        'display_date'                => false,
                                        'display_price'               => $display_price,
                                        'display_function'            => $display_function,
                                        'replace_like_with_follow'    => $replace_like_with_follow,
                                ));
                            ?>
                        </li>
                    <?php endforeach; ?>
                </ul>
            </section>
        </section>
        <section class="right column">
            <section class="pick">
                <h3>今日精选</h3>
                <div class="nivoSlider" id="todays-pick">

                <?php if(!empty($this->picklist)):?>
                    <?php foreach ($this->picklist as $item):?>
                        <?php if(!empty($item->featured_photo)):?>
                                <a href="<?php echo $item->url()?>">
                                    <img src="<?php echo $this->thumbnail()->resizeAndCrop($item->featured_photo, 299, 200)?>" alt="" title="<?php echo htmlentities(preg_replace('#([\n|\r])#', '', $item->title_original), ENT_COMPAT, 'utf-8')?>" />
                                </a>
                            <div class="nivo-caption">
                                <p>Nice Flatshare needed @ hong kong side </p>
                            </div>  
                        <?php endif;?>
                    <?php endforeach;?>
                <?php endif;?>
                </div>
            </section>  
            <section class="ad medium"> 
                <a href="#"><img src="images/ad_300_250.jpg"></a> 
            </section>
            <?php if($this->category->id == 'mc52'):?>
                <section class="popular company list">    
                    <h3>热门公司</h3>
                        <ul>
                        <?php foreach ($this->popular_company as $item):?>
                            <li>
                                <dl>
                                    <dt>
                                        <a href="<?php echo $item->url()?>"><?php echo $item->company_name?></a>
                                    </dt>
                                    <dd class="user">
                                        <?php 
                                            $is_follow = Model_Follow::isFollowing($item->_id);
                                            $follow_button = '<a href="#" rel="'.$this->geturl(($is_follow ? 'unfollow' : 'follow'),'follow', array('id' => (string)$item->_id)).'" class="follow to_follow '.($is_follow ? 'selected' : '').'"><span>关注<em>'.Model_Follow::getCountFollowers($item->_id).'</em></span></a>';
                                            echo $follow_button;
                                        ?>
                                    </dd>
                                </dl>
                            </li>
                        <?php endforeach;?>
                        </ul>
                </section>            
            <?php else:?>
                <section class="popular gallery vert">    
                    <h3>人气宝贝</h3>
                    <ul>
                        <?php foreach ($this->popular as $item):?>
                            <li>
                                <?php
                                    $this->partial()->setObjectKey('model');
                                    echo $this->partial(
                                        'index/listing-element.phtml',
                                        'search',
                                        array(
                                            'item'                  => $item,
                                            'photo_width'           => 56,
                                            'photo_height'          => 56,
                                            'photo_params'          => array(),
                                            'display_photo_if_not_exists' => true,
                                            'display_date'                => false,
                                            'display_category'            => false,
                                            'display_customization'       => false,
                                            'display_user'                => false,
                                            'lazy_loading'                => false, 
                                    ));
                                ?>
                            </li>
                        <?php endforeach;?>
                    </ul>
                </section>
            <?php endif;?>
        </section>
    </section>
</section>
</article>
